package com.douwong.student.rxjava;

import okhttp3.OkHttpClient;
import retrofit2.CallAdapter;
import retrofit2.Converter;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * @autor yichao
 * @time 2017/3/2318:30
 * @des ${TODO}
 */
public class NetWork {
    private static OkHttpClient okHttpClient = new OkHttpClient();


    private static Converter.Factory gsonConverterFactory = GsonConverterFactory.create();
    private static CallAdapter.Factory rxJavaCallAdapterFactory = RxJavaCallAdapterFactory.create();
    private static EndPointInterface sEndPointInterface;

    public static EndPointInterface getEndPointInterface() {
        if (sEndPointInterface == null) {

            Retrofit retrofit = new Retrofit.Builder()
                    .client(okHttpClient)
                    .baseUrl(EndPointInterface.BASEURL)
                    .addConverterFactory(gsonConverterFactory)
                    .addCallAdapterFactory(rxJavaCallAdapterFactory)
                    .build();
            sEndPointInterface = retrofit.create(EndPointInterface.class);

        }
        return sEndPointInterface;
    }
    /**上传头像*/
    public static EndPointInterface getHeadEndPointInterface() {

            Retrofit retrofit = new Retrofit.Builder()
                    .client(okHttpClient)
                    .baseUrl("http://edu.douwong.com/api/")
                    .addConverterFactory(gsonConverterFactory)
                    .addCallAdapterFactory(rxJavaCallAdapterFactory)
                    .build();
        return  retrofit.create(EndPointInterface.class);
    }
}
